package repository

import (
	"rustdesk_api_server/global"
	"rustdesk_api_server/models"
)

var Users = new(UserRepository)

type UserRepository struct{}

func (u UserRepository) GetUserByUsername(username string) (user models.User, err error) {
	err = global.DB.First(&user, "username = ?", username).Error
	return user, err
}

func (u UserRepository) AddUser(user models.User) (models.User, error) {
	return user, global.DB.Create(&user).Error
}

func (u UserRepository) Update(user models.User) error {
	return global.DB.Updates(&user).Error
}
